<?php
	require_once 'conn/DBconnect.php';
	require_once 'email/registration.php';
	session_start();
	
	$params[0] = "";
	$params[1] = "";
	$params[2] = $_POST['username'];
	$params[3] = "RESET_PASSWORD";
			
	$loginPROC = "CALL SP_VALIDATOR('" . implode("', '", $params) . "');";
	$result = mysqli_query($mysqlLink, $loginPROC);
	$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
			
	if( $row["err_id"] != '-1')
	{
		echo $row["err_id"];
		RegEmail::resetPassword($_POST['username'], $row["newPassword"]);
	}
	else 
	{
		echo $row["err_code"];
	}